package com.treeliked.service.impl;

import com.treeliked.service.FileService;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * TODO
 *
 * @author lqs2
 * @date 2018/11/29, Thu
 */
public class FileServiceImpl implements FileService {

    @Override
    public void saveFile(InputStream ips, File file) throws Exception {
        FileUtils.copyInputStreamToFile(ips, file);
    }

    @Override
    public void downloadFile(File file, OutputStream ops) throws Exception {
        IOUtils.copy(new FileInputStream(file), ops);
    }

}
